from langchain.chains import ConversationChain
from langchain.memory import ConversationBufferWindowMemory
from tool import langchain_client
if __name__ == '__main__':
    # k=1表明只保留一个对话记忆
    memory = ConversationBufferWindowMemory(k=1)
    conversation = ConversationChain(llm=langchain_client, memory=memory, verbose=False)

    print("第一轮对话:")
    print(conversation.predict(input="你好, 我叫皮皮鲁"))
    print("第二轮对话:")
    print(conversation.predict(input="1+1等于多少?"))
    print("第三轮对话:")
    print(conversation.predict(input="我叫什么名字?"))